package jdtoextension;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.juancavallotti.jdto.SinglePropertyValueMerger;

/**
 */
public class DateTimeFormatMerger implements SinglePropertyValueMerger<String, Object> {

    @Override
    public String mergeObjects(final Object value, final String extraParam) {

        // create a dateformat with the format String
        DateTimeFormatter fmt = DateTimeFormat.forPattern(extraParam);

        DateTime target = (DateTime) value;

        return fmt.print(target);
    }

}
